import { observable, action, runInAction } from 'mobx'
import { post } from 'lib/net'
import CommonVM from 'cvm/common'
import * as api from 'lib/constants/api'
import Toast from 'components/toast'

export default class MineVM extends CommonVM {
  constructor (props) {
    super()
    this.props = props
    this.fetchData()
  }
  // 个人中心数据
  @observable data = null

  // 获取个人中心数据
  @action fetchData = async () => {
    let params = {ID: this.userId}
    Toast.loading()
    let res = await post(api.GET_MY_INFO, params)
    Toast.loading(2)
    if (res.state === 1) {
      runInAction(() => {
        this.data = res.data
      })
    }
  }
}
